#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define For(i,x,j)  for(ll (i)=(x);(i)<=(j);++(i))
using namespace std;
inline ll rea(){
	ll t=1,c=0;char x=getchar();
	while(x<'0'||x>'9'){
		if(x=='-')	t=-1;
		x=getchar();
	}
	while(x>='0'&&x<='9'){
		c=c*10+x-'0';
		x=getchar();
	}return t*c;
}
struct line{
	ll l,r;
	bool operator <(const line &aa)const{
		return l<aa.l;
	}
}pln[110000],plw[101000];
struct shij{
	ll k;
	bool operator <(const shij&aa)const{
		return k>aa.k;
	}
};
priority_queue<shij> qlk;
ll n,mn,mw,ans,p=0;
ll js(ll t,ll c){
	ll w=0,w1=0;
	For(i,1,mn){
		ll x=pln[i].l,y=pln[i].r;
		while(!qlk.empty()){
			if(x>=qlk.top().k){
				qlk.pop();t++;
			}
			else	break;
		}
		if(t){
			t--;w++;
			qlk.push({y});
		}
	}
	if(w==mn)	p=1;
	while(!qlk.empty())	qlk.pop();
	For(i,1,mw){
		ll x=plw[i].l,y=plw[i].r;
		while(!qlk.empty()){
			if(x>=qlk.top().k){
				qlk.pop();c++;
			}
			else	break;
		}
		if(c){
			c--;w1++;
			qlk.push({y});
		}
	}
	while(!qlk.empty())	qlk.pop();
	return w+w1;
}
int main(){
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	n=rea();mn=rea();mw=rea();
	For(i,1,mn){
		pln[i].l=rea();
		pln[i].r=rea();
	}
	For(i,1,mw){
		plw[i].l=rea();
		plw[i].r=rea();
	}
	sort(pln+1,pln+1+mn);
	sort(plw+1,plw+1+mw);
	ll l1=0,r1=min(n,mn);
	For(i,0,r1){
		ans=max(ans,js(i,n-i));
		if(p==1)	break;
	}	
	cout<<ans<<endl;
	return 0;
}

